
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>分布式事务 · tgor note</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="tgor">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-toc-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="分布式事务.html" />
    
    
    <link rel="prev" href="../Redis/Redis.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Me
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../category/微服务.html">
            
                <a href="../category/微服务.html">
            
                    
                    微服务
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Java-Spring/Feign.html">
            
                <a href="../Java-Spring/Feign.html">
            
                    
                    HTTP客户端Feign
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="限流.html">
            
                <a href="限流.html">
            
                    
                    限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../运维/Nginx限流.html">
            
                <a href="../运维/Nginx限流.html">
            
                    
                    限流Nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../Java-Spring/负载均衡.html">
            
                <a href="../Java-Spring/负载均衡.html">
            
                    
                    负载均衡
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../运维/Nginx负载均衡.html">
            
                <a href="../运维/Nginx负载均衡.html">
            
                    
                    负载均衡Nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="熔断Hystrix.html">
            
                <a href="熔断Hystrix.html">
            
                    
                    熔断Hystrix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="缓存.html">
            
                <a href="缓存.html">
            
                    
                    缓存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="缓存.html">
            
                <a href="缓存.html#本地缓存">
            
                    
                    本地缓存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html">
            
                    
                    分布式缓存Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.10" data-path="分布式事务.html">
            
                <a href="分布式事务.html">
            
                    
                    分布式事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="分布式事务.html">
            
                <a href="分布式事务.html#事务消息">
            
                    
                    可靠事务消息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="../Java-Spring/业务监控.html">
            
                <a href="../Java-Spring/业务监控.html">
            
                    
                    业务监控
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.13" data-path="分布式定时作业.html">
            
                <a href="分布式定时作业.html">
            
                    
                    分布式作业调度ElasticJob
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.14" data-path="../Java-ORM/ORM.html">
            
                <a href="../Java-ORM/ORM.html">
            
                    
                    ORM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.15" data-path="分布式系统及CAP原理.html">
            
                <a href="分布式系统及CAP原理.html">
            
                    
                    分布式系统及CAP原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.16" data-path="../MQ/RabbitMQ笔记.html">
            
                <a href="../MQ/RabbitMQ笔记.html">
            
                    
                    消息驱动Rabbitmq
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../category/数据库.html">
            
                <a href="../category/数据库.html">
            
                    
                    数据库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Mysql/经典数据库设计案例.html">
            
                <a href="../Mysql/经典数据库设计案例.html">
            
                    
                    mysql设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../Mysql/Mysql事务与锁.html">
            
                <a href="../Mysql/Mysql事务与锁.html">
            
                    
                    mysql事务与锁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../Mysql/mysql数据类型.html">
            
                <a href="../Mysql/mysql数据类型.html">
            
                    
                    mysql数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../Mysql/mysql索引及查询.html">
            
                <a href="../Mysql/mysql索引及查询.html">
            
                    
                    mysql索引与查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../Mysql/mysql索引及查询.html">
            
                <a href="../Mysql/mysql索引及查询.html#查询语句设计准则">
            
                    
                    mysql查询语句设计准则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../Mysql/mysql性能测试.html">
            
                <a href="../Mysql/mysql性能测试.html">
            
                    
                    mysql性能测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../Mysql/mysql主从同步与读写分离.html">
            
                <a href="../Mysql/mysql主从同步与读写分离.html">
            
                    
                    mysql主从同步与读写分离
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../Java-Spring/SpringBoot事务注解@Transactional.html">
            
                <a href="../Java-Spring/SpringBoot事务注解@Transactional.html">
            
                    
                    Spring事务注解@Transactional
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../数据结构与算法/位运算应用实例.html">
            
                <a href="../数据结构与算法/位运算应用实例.html">
            
                    
                    位运算应用实例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../Mongodb-Client/morphia-API汇总.html">
            
                <a href="../Mongodb-Client/morphia-API汇总.html">
            
                    
                    morphia API汇总
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="../Mongodb-Client/mongo驱动连接.html">
            
                <a href="../Mongodb-Client/mongo驱动连接.html">
            
                    
                    mongodb驱动与连接
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="../Mongodb/mongodb-ObjectId实践.html">
            
                <a href="../Mongodb/mongodb-ObjectId实践.html">
            
                    
                    mongodb ObjectId实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="../Mongodb/mongodb角色权限.html">
            
                <a href="../Mongodb/mongodb角色权限.html">
            
                    
                    mongodb角色权限
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../category/java并发.html">
            
                <a href="../category/java并发.html">
            
                    
                    Java并发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Java-Base/Java并发.html">
            
                <a href="../Java-Base/Java并发.html">
            
                    
                    Java并发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Java-Base/Java并发.html">
            
                <a href="../Java-Base/Java并发.html#锁">
            
                    
                    Java并发之锁设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Java-Base/Java并发.html">
            
                <a href="../Java-Base/Java并发.html#synchronized">
            
                    
                    Java并发之synchronized
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../Java-Base/Java之Lock.html">
            
                <a href="../Java-Base/Java之Lock.html#reentrantlock">
            
                    
                    Java Lock之ReentrantLock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../Java-Base/Java之Lock.html">
            
                <a href="../Java-Base/Java之Lock.html#reentrantreadwritelock">
            
                    
                    Java Lock之ReentrantReadWriteLock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../Java-Base/Java之Future.html">
            
                <a href="../Java-Base/Java之Future.html">
            
                    
                    Java Future
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../Java-Base/Java之Future.html">
            
                <a href="../Java-Base/Java之Future.html#futuretask">
            
                    
                    Java Future之FutureTask
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../Java-Base/Java之Future.html">
            
                <a href="../Java-Base/Java之Future.html#completablefuture">
            
                    
                    Java Future之CompletableFuture
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../Java-Base/Java之Future.html">
            
                <a href="../Java-Base/Java之Future.html#forkjointask">
            
                    
                    Java Future之ForkJoinTask
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../Java-Base/Java之Thread.html">
            
                <a href="../Java-Base/Java之Thread.html">
            
                    
                    Java Thread
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../category/redis.html">
            
                <a href="../category/redis.html">
            
                    
                    Redis
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#集群">
            
                    
                    Redis集群
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#消息订阅">
            
                    
                    Redis消息订阅
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#lua">
            
                    
                    Redis Lua脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../Redis/Redis.html">
            
                <a href="../Redis/Redis.html#配置汇总">
            
                    
                    Redis配置汇总
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../category/运维.html">
            
                <a href="../category/运维.html">
            
                    
                    运维
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../运维/Linux常用操作汇总.html">
            
                <a href="../运维/Linux常用操作汇总.html">
            
                    
                    Linux常用操作汇总
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../运维/阿里云笔记.html">
            
                <a href="../运维/阿里云笔记.html">
            
                    
                    阿里云笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../category/nginx.html">
            
                <a href="../category/nginx.html">
            
                    
                    Nginx
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../运维/Nginx学习笔记.html">
            
                <a href="../运维/Nginx学习笔记.html">
            
                    
                    Nginx基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../运维/Nginx负载均衡.html">
            
                <a href="../运维/Nginx负载均衡.html">
            
                    
                    Nginx负载均衡
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../运维/Nginx限流.html">
            
                <a href="../运维/Nginx限流.html">
            
                    
                    Nginx限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../运维/Nginx学习笔记.html">
            
                <a href="../运维/Nginx学习笔记.html#六、其他">
            
                    
                    Nginx客户端辅助技巧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../category/容器化.html">
            
                <a href="../category/容器化.html">
            
                    
                    容器化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../Docker/docker笔记.html">
            
                <a href="../Docker/docker笔记.html">
            
                    
                    Docker学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../Docker/docker笔记.html">
            
                <a href="../Docker/docker笔记.html#基础操作">
            
                    
                    Docker基础操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../Docker/docker笔记.html">
            
                <a href="../Docker/docker笔记.html#dockerfile">
            
                    
                    DockerFile
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../category/Web.html">
            
                <a href="../category/Web.html">
            
                    
                    Web
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../运维/Http入坑Https笔记.html">
            
                <a href="../运维/Http入坑Https笔记.html">
            
                    
                    Http入坑Https笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../Web/阿里云OSS.html">
            
                <a href="../Web/阿里云OSS.html">
            
                    
                    OSS
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../category/java基础.html">
            
                <a href="../category/java基础.html">
            
                    
                    Java基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../Java-Base/Java基础.html">
            
                <a href="../Java-Base/Java基础.html#jvm">
            
                    
                    JVM基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../Java-Base/Java基础.html">
            
                <a href="../Java-Base/Java基础.html#语法糖">
            
                    
                    Java语法糖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../Java-Base/Java基础.html">
            
                <a href="../Java-Base/Java基础.html#数据结构">
            
                    
                    Java数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../Java-Base/Java8函数式编程.html">
            
                <a href="../Java-Base/Java8函数式编程.html">
            
                    
                    java8函数式编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../Java-Base/ArrayList源码分析.html">
            
                <a href="../Java-Base/ArrayList源码分析.html">
            
                    
                    JDK源码分析ArrayList
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../Java-Base/HashMap源码分析.html">
            
                <a href="../Java-Base/HashMap源码分析.html">
            
                    
                    JDK源码分析HashMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../Java-Base/Java注解.html">
            
                <a href="../Java-Base/Java注解.html">
            
                    
                    Java注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../Java-Base/Timsort排序算法.html">
            
                <a href="../Java-Base/Timsort排序算法.html">
            
                    
                    Timsort排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.9" data-path="../Java-Base/插入排序分析与Java实现.html">
            
                <a href="../Java-Base/插入排序分析与Java实现.html">
            
                    
                    插入排序分析与Java实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../category/工具与规范.html">
            
                <a href="../category/工具与规范.html">
            
                    
                    工具与规范
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../工具/Maven使用技巧汇总.html">
            
                <a href="../工具/Maven使用技巧汇总.html">
            
                    
                    Maven使用技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../编码规范/Java编码规范.html">
            
                <a href="../编码规范/Java编码规范.html">
            
                    
                    Java编码规范
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../category/OLAP.html">
            
                <a href="../category/OLAP.html">
            
                    
                    OLAP
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../数据处理/storm学习笔记.html">
            
                <a href="../数据处理/storm学习笔记.html">
            
                    
                    流式计算Storm学习笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../category/数据运营.html">
            
                <a href="../category/数据运营.html">
            
                    
                    数据运营
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../数据运营/增长黑客数据运营.html">
            
                <a href="../数据运营/增长黑客数据运营.html">
            
                    
                    增长黑客-数据运营
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../category/前端技术栈.html">
            
                <a href="../category/前端技术栈.html">
            
                    
                    前端技术栈
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../前端/JavaScript设计模式.html">
            
                <a href="../前端/JavaScript设计模式.html">
            
                    
                    JavaScript设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../前端/html相对路径与绝对路径.html">
            
                <a href="../前端/html相对路径与绝对路径.html">
            
                    
                    Html相对路径与绝对路径
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../前端/微信小程序学习笔记.html">
            
                <a href="../前端/微信小程序学习笔记.html">
            
                    
                    微信小程序学习笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../category/个人.html">
            
                <a href="../category/个人.html">
            
                    
                    个人
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../个人/简历.html">
            
                <a href="../个人/简历.html">
            
                    
                    简历
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >分布式事务</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;">&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;</h1>
<p><a href="http://naotu.baidu.com/file/fa4c4dab59e483703c07924d60bf2489?token=804d83c94d472173" target="_blank">&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#x8111;&#x56FE;</a></p>
<hr>
<p>&#x4FDD;&#x8BC1;&#x5206;&#x5E03;&#x5F0F;&#x7CFB;&#x7EDF;&#x6570;&#x636E;&#x4E00;&#x81F4;&#x6027;&#xFF0C;&#x662F;&#x5FAE;&#x670D;&#x52A1;&#x96C6;&#x7FA4;&#x6700;&#x6838;&#x5FC3;&#x7684;&#x5DE5;&#x4F5C;</p>
<h1 id="&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#x6A21;&#x578B;tcc">&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#x6A21;&#x578B;TCC</h1>
<p><img src="assets/1574823986548.png" alt="1574823986548"></p>
<p>&#x6D3B;&#x52A8;&#x7BA1;&#x7406;&#x5668;&#x8BB0;&#x5F55;&#x4E86;&#x5168;&#x5C40;&#x4E8B;&#x52A1;&#x7684;&#x63A8;&#x8FDB;&#x72B6;&#x6001;&#x4EE5;&#x53CA;&#x5404;&#x5B50;&#x4E8B;&#x52A1;&#x7684;&#x6267;&#x884C;&#x72B6;&#x6001;&#xFF0C;&#x8D1F;&#x8D23;&#x63A8;&#x8FDB;&#x5404;&#x4E2A;&#x5B50;&#x4E8B;&#x52A1;&#x5171;&#x540C;&#x8FDB;&#x884C;&#x63D0;&#x4EA4;&#x6216;&#x8005;&#x56DE;&#x6EDA;&#x3002;&#x540C;&#x65F6;&#x8D1F;&#x8D23;&#x5728;&#x5B50;&#x4E8B;&#x52A1;&#x5904;&#x7406;&#x8D85;&#x65F6;&#x540E;&#x4E0D;&#x505C;&#x91CD;&#x8BD5;&#xFF0C;&#x91CD;&#x8BD5;&#x4E0D;&#x6210;&#x529F;&#x540E;&#x8F6C;&#x624B;&#x5DE5;&#x5904;&#x7406;&#xFF0C;&#x7528;&#x4EE5;&#x4FDD;&#x8BC1;&#x4E8B;&#x52A1;&#x7684;&#x6700;&#x7EC8;&#x4E00;&#x81F4;&#x6027;&#x3002;</p>
<p>&#x7F3A;&#x70B9;&#xFF1A;&#x76F8;&#x6BD4;&#x4E8E; SAGA &#x6A21;&#x5F0F;&#xFF0C;TCC &#x6A21;&#x5F0F;&#x591A;<strong>&#x589E;&#x52A0;&#x4E86;&#x4E00;&#x4E2A;&#x72B6;&#x6001;</strong>&#xFF0C;&#x5BFC;&#x81F4;&#x5728;&#x4E1A;&#x52A1;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x590D;&#x6742;&#x5EA6;&#x4E0A;&#x5347;&#xFF0C;&#x800C;&#x4E14;<strong>&#x534F;&#x8C03;&#x5668;&#x4E0E;&#x5B50;&#x4E8B;&#x52A1;&#x7684;&#x901A;&#x4FE1;&#x8FC7;&#x7A0B;&#x589E;&#x52A0;&#xFF0C;&#x72B6;&#x6001;&#x8F6E;&#x8F6C;&#x5904;&#x7406;&#x4E5F;&#x66F4;&#x4E3A;&#x590D;&#x6742;</strong>&#x3002;</p>
<p>TCC&#x6A21;&#x578B;&#x4E0D;&#x662F;&#x6700;&#x4F18;&#x65B9;&#x6848;</p>
<h1 id="&#x540C;&#x6B65;&#x63A5;&#x53E3;&#x8BBE;&#x8BA1;">&#x540C;&#x6B65;&#x63A5;&#x53E3;&#x8BBE;&#x8BA1;</h1>
<p>&#x8003;&#x8651;&#x5230;&#x7F51;&#x7EDC;&#x5F02;&#x5E38;&#x3001;&#x670D;&#x52A1;&#x5B95;&#x673A;&#x7B49;&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x4E00;&#x4E2A;&#x5BF9;&#x4E8E;&#x53EF;&#x9760;&#x6027;&#x6709;&#x4E25;&#x683C;&#x8981;&#x6C42;&#x7684;&#x7CFB;&#x7EDF;&#x662F;&#x4E0D;&#x80FD;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&quot;&#x5B8C;&#x5168;&#x76F8;&#x4FE1;&#x6D88;&#x8D39;&#x7AEF;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&quot;&#x7684;&#x8BBE;&#x8BA1;&#x3002;</p>
<h2 id="&#x6D88;&#x8D39;&#x7AEF;&#x63A5;&#x53E3;&#x8BBE;&#x8BA1;&#x539F;&#x5219;">&#x6D88;&#x8D39;&#x7AEF;&#x63A5;&#x53E3;&#x8BBE;&#x8BA1;&#x539F;&#x5219;</h2>
<ol>
<li><p>&#x5EFA;&#x7ACB;&#x8BA2;&#x5355;</p>
</li>
<li><p>&#x63A5;&#x53E3;&#x5E42;&#x7B49;&#xFF0C;&#x53EF;&#x91CD;&#x8BD5;&#x8BA2;&#x5355;&#xFF1B;</p>
</li>
<li><p>&#x8BA2;&#x5355;&#x53EF;&#x67E5;&#x8BE2;&#x72B6;&#x6001;</p>
</li>
</ol>
<h2 id="&#x751F;&#x4EA7;&#x7AEF;&#x8BBE;&#x8BA1;&#x539F;&#x5219;">&#x751F;&#x4EA7;&#x7AEF;&#x8BBE;&#x8BA1;&#x539F;&#x5219;</h2>
<ol>
<li>&#x8C03;&#x7528;&#x6D88;&#x8D39;&#x7AEF;&#x63A5;&#x53E3;&#x7EDD;&#x4E0D;&#x80FD;&#x5305;&#x542B;&#x5728;&#x672C;&#x5730;&#x4E8B;&#x52A1;&#x4E2D;&#xFF0C;&#x8FD9;&#x79CD;&#x64CD;&#x4F5C;&#x5F88;&#x591A;&#x65F6;&#x5019;&#x90FD;&#x4F1A;&#x5BFC;&#x81F4;mysql&#x6709;&#x5927;&#x91CF;&#x957F;&#x4E8B;&#x52A1;&#xFF0C;&#x5F71;&#x54CD;&#x6027;&#x80FD;&#xFF1B;</li>
<li>&#x6D88;&#x8D39;&#x7AEF;&#x8FD4;&#x56DE;&#x6210;&#x529F;&#xFF0C;&#x53EF;&#x4EE5;&#x89C6;&#x4E3A;&#x64CD;&#x4F5C;&#x6210;&#x529F;&#xFF0C;&#x5E76;&#x6267;&#x884C;&#x6210;&#x529F;&#x4E0B;&#x7684;&#x64CD;&#x4F5C;&#xFF1B;</li>
<li>&#x6D88;&#x8D39;&#x7AEF;&#x8FD4;&#x56DE;&#x5931;&#x8D25;&#xFF0C;&#x53EF;&#x4EE5;&#x89C6;&#x4E3A;&#x64CD;&#x4F5C;&#x5931;&#x8D25;&#xFF0C;&#x5E76;&#x6267;&#x884C;&#x5931;&#x8D25;&#x4E0B;&#x7684;&#x64CD;&#x4F5C;&#xFF1B;</li>
<li>&#x6D88;&#x8D39;&#x7AEF;&#x54CD;&#x5E94;&#x8D85;&#x65F6;&#x3001;&#x6216;&#x56E0;&#x6D88;&#x8D39;&#x7AEF;&#x7684;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x65E0;&#x6CD5;&#x8FD4;&#x56DE;&#x6700;&#x7EC8;&#x7ED3;&#x679C;&#x65F6;&#xFF0C;&#x751F;&#x4EA7;&#x7AEF;&#x5E94;&#x4E3B;&#x52A8;&#x67E5;&#x8BE2;&#x72B6;&#x6001;</li>
</ol>
<h2 id="&#x8BBE;&#x8BA1;&#x8303;&#x4F8B;">&#x8BBE;&#x8BA1;&#x8303;&#x4F8B;</h2>
<p>&#x4E3E;&#x4F8B;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#xFF1A;&#x4F7F;&#x7528;&#x6EE1;&#x51CF;&#x5238;&#x6295;&#x8D44;&#x9879;&#x76EE;</p>
<p><img src="assets/1574821320873.png" alt="1574821320873"></p>
<h1 id="&#x4E8B;&#x52A1;&#x6D88;&#x606F;">&#x4E8B;&#x52A1;&#x6D88;&#x606F;</h1>
<p>&#x672C;&#x8D28;&#x5C31;&#x662F;&#xFF1A;</p>
<ul>
<li>&#x751F;&#x4EA7;&#x7AEF;&#xFF1A;&#x53D1;&#x6D88;&#x606F;&#x4E0E;&#x672C;&#x5730;&#x4E8B;&#x52A1;&#x662F;&#x539F;&#x5B50;&#x64CD;&#x4F5C;</li>
<li>&#x6D88;&#x8D39;&#x7AEF;&#xFF1A;&#x63A5;&#x6536;&#x6D88;&#x606F;&#x4E0E;&#x672C;&#x5730;&#x4E8B;&#x52A1;&#x662F;&#x539F;&#x5B50;&#x64CD;&#x4F5C;</li>
</ul>
<h2 id="&#x4F20;&#x7EDF;&#x4E8B;&#x52A1;&#x6D88;&#x606F;">&#x4F20;&#x7EDF;&#x4E8B;&#x52A1;&#x6D88;&#x606F;</h2>
<p>&#x53D1;&#x6D88;&#x606F;&#x5305;&#x542B;&#x5728;&#x672C;&#x5730;&#x4E8B;&#x52A1;&#x4E2D;&#xFF0C;&#x9996;&#x5148;&#x5F00;&#x542F;&#x4E8B;&#x52A1;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x8FDB;&#x884C;&#x6D88;&#x606F;&#x53D1;&#x9001;&#xFF0C;&#x6700;&#x540E;&#x8FDB;&#x884C;&#x6D88;&#x606F;&#x7684; commit &#x6216;&#x8005;&#x662F; rollback&#x3002;&#x8FD9;&#x4E2A;&#x8FC7;&#x7A0B;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x5728;&#x6D88;&#x606F;&#x53D1;&#x9001;&#x6210;&#x529F;&#x7684;&#x540C;&#x65F6;&#x672C;&#x5730;&#x4E8B;&#x52A1;&#x4E5F;&#x4E00;&#x5B9A;&#x6210;&#x529F;&#x6267;&#x884C;&#xFF0C;&#x4F46;&#x4E8B;&#x52A1;&#x7C92;&#x5EA6;&#x4E0D;&#x597D;&#x63A7;&#x5236;&#xFF0C;&#x800C;&#x4E14;&#x4F1A;&#x5BFC;&#x81F4;&#x6027;&#x80FD;&#x6025;&#x5267;&#x4E0B;&#x964D;&#xFF0C;&#x540C;&#x65F6;&#x4F9D;&#x7136;&#x65E0;&#x6CD5;&#x89E3;&#x51B3;&#x672C;&#x5730;&#x4E8B;&#x52A1;&#x6267;&#x884C;&#x4E0E;&#x6D88;&#x606F;&#x53D1;&#x9001;&#x7684;&#x539F;&#x5B50;&#x6027;&#x95EE;&#x9898;&#x3002;</p>
<h2 id="rocketmq&#x4E8B;&#x52A1;&#x6D88;&#x606F;">RocketMQ&#x4E8B;&#x52A1;&#x6D88;&#x606F;</h2>
<h3 id="&#x751F;&#x4EA7;&#x7AEF;&#x53D1;&#x9001;&#x6D88;&#x606F;">&#x751F;&#x4EA7;&#x7AEF;&#x53D1;&#x9001;&#x6D88;&#x606F;</h3>
<p><img src="assets/1574826440529.png" alt="1574826440529"></p>
<p>&#x4E0E;&#x4F20;&#x7EDF;&#x4E8B;&#x52A1;&#x6D88;&#x606F;&#x6BD4;&#x8F83;&#xFF0C;RocketMQ&#x4E8B;&#x52A1;&#x6D88;&#x606F;producer&#x662F;&#x5982;&#x4F55;&#x786E;&#x4FDD;&#x539F;&#x5B50;&#x5462;&#xFF1F;&#x5C31;&#x597D;&#x6BD4;&#x6211;&#x4EEC;&#x5BC4;&#x5FEB;&#x9012;&#x4E00;&#x6837;&#xFF1A;</p>
<blockquote>
<p>&#x4F20;&#x7EDF;&#x4E8B;&#x52A1;&#x6D88;&#x606F;&#x903B;&#x8F91;</p>
</blockquote>
<p><img src="assets/1574828575869.png" alt="1574828575869"></p>
<blockquote>
<p>RocketMQ&#x53D1;&#x6D88;&#x606F;&#x903B;&#x8F91;</p>
</blockquote>
<p><img src="assets/1574828635119.png" alt="1574828635119"></p>
<p>&#x5BF9;&#x6BD4;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x987A;&#x4E30;&#x6536;&#x4EF6;&#xFF0C;&#x4F46;&#x4E5F;&#x53EF;&#x80FD;&#x4E22;&#x554A;&#xFF1B;&#x800C;&#x540E;&#x8005;&#x7684;&#x7B56;&#x7565;&#x662F;&#xFF0C;&#x9001;&#x5230;&#x5BA2;&#x6237;&#x9762;&#x524D;&#xFF0C;&#x518D;&#x56DE;&#x5934;&#x8981;&#x4F60;&#x786E;&#x8BA4;&#x662F;&#x4E0D;&#x662F;&#x6D3E;&#x9001;&#xFF0C;&#x8FD9;&#x4E2A;&#x9636;&#x6BB5;&#x5C31;&#x662F;RocketMQ&#x7684;prepare&#x9636;&#x6BB5;&#x3002;</p>
<h3 id="&#x6D88;&#x8D39;&#x7AEF;&#x63A5;&#x6536;&#x6D88;&#x606F;">&#x6D88;&#x8D39;&#x7AEF;&#x63A5;&#x6536;&#x6D88;&#x606F;</h3>
<p><img src="assets/1574826575163.png" alt="1574826575163"></p>
<p>consumer&#x53EF;&#x4EE5;&#x8BA9;&#x63A5;&#x6536;MQ&#x4E0E;&#x4E8B;&#x52A1;&#x4FDD;&#x6301;&#x539F;&#x5B50;&#x7684;&#x5173;&#x952E;&#x5728;&#x4E8E;&#xFF0C;RocketMQ&#x7684;ack&#x786E;&#x8BA4;&#x662F;&#x5426;&#x53EF;&#x9760;&#xFF1F;</p>
<ul>
<li>&#x5F53;consumer&#x6D88;&#x8D39;&#x6D88;&#x606F;&#x65F6;&#xFF0C;&#x6210;&#x529F;&#x5219;&#x60F3;RocketMQ&#x8FD4;&#x56DE;&#x201C;<strong>CONSUME_SUCCESS</strong>&#x201D;</li>
<li>&#x53CD;&#x4E4B;&#x51FA;&#x73B0;&#x5F02;&#x5E38;&#x5219;&#x9700;&#x8981;&#x8FD4;&#x56DE;&#x201C;<strong>RECONSUME_LATER</strong>&#x201D;</li>
</ul>
<p>&#x4E0E;&#x4F20;&#x7EDF;&#x4E8B;&#x52A1;&#x6D88;&#x606F;&#x6CA1;&#x6709;&#x533A;&#x522B;</p>
<h3 id="&#x8425;&#x9500;&#x670D;&#x52A1;&#x6846;&#x67B6;&#x5DE5;&#x4F5C;&#x539F;&#x7406;">&#x8425;&#x9500;&#x670D;&#x52A1;&#x6846;&#x67B6;&#x5DE5;&#x4F5C;&#x539F;&#x7406;</h3>
<p><img src="assets/1583933503039.png" alt="1583933503039"></p>
<p>&#x4E3E;&#x4F8B;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#xFF0C;&#x73B0;&#x91D1;&#x4E70;&#x798F;&#x888B;&#xFF0C;client&#x5904;&#x7406;&#x6263;&#x94B1;&#x4E1A;&#x52A1;&#xFF0C;consumer&#x5904;&#x7406;&#x53D1;&#x653E;&#x798F;&#x888B;&#x4E1A;&#x52A1;</p>
<ol>
<li>Client&#x901A;&#x77E5;MQ Server&#xFF1A;&#x6211;&#x8981;&#x6263;&#x94B1;&#x4E86;</li>
<li>MQ Server&#x53D1;&#x9001;&#x9884;&#x6263;&#x6B3E;&#x4E8B;&#x4EF6;&#x5230;MQ&#xFF1A;&#x8001;&#x5927;&#x54E5;&#x51C6;&#x5907;&#x6263;&#x94B1;&#x4E86;&#xFF0C;&#x4F60;&#x51C6;&#x5907;&#x597D;&#x8DDF;&#x6211;&#x8BF4;</li>
<li>MQ&#x56DE;&#x590D;&#xFF1A;&#x884C;&#x4E86;&#xFF0C;&#x6263;&#x5427;</li>
<li>Client&#x5F00;&#x542F;&#x672C;&#x5730;&#x4E8B;&#x52A1;&#xFF0C;&#x53BB;&#x73B0;&#x91D1;&#x5E93;&#x6263;&#x94B1;&#x4E86;</li>
<li>&#x4E8B;&#x52A1;&#x6210;&#x6216;&#x4E0D;&#x6210;&#xFF0C;&#x4E0D;&#x6210;&#x81EA;&#x5DF1;&#x5904;&#x7406;</li>
<li>&#x6210;&#x529F;&#x5219;&#x901A;&#x77E5;MQ</li>
<li>MQ&#x53D1;&#x9001;&#x6263;&#x94B1;&#x6210;&#x529F;&#x4E8B;&#x4EF6;&#x5230;Consumer</li>
<li>Consumer&#x6015;&#x6B7B;&#xFF0C;&#x5148;&#x5427;&#x6263;&#x94B1;&#x4E8B;&#x4EF6;&#x8BB0;&#x5230;&#x5907;&#x5FD8;</li>
<li>&#x5907;&#x5FD8;&#x597D;&#x4E86;</li>
<li>Consumer&#x56DE;&#x590D;MQ&#xFF0C;&#x884C;&#x4E86;&#xFF0C;&#x6211;&#x8BB0;&#x5F97;&#x8FD9;&#x4EF6;&#x4E8B;&#x4E86;&#xFF0C;&#x6CA1;&#x4F60;&#x4E8B;&#x4E86;</li>
<li>Consumer&#x4E00;&#x770B;&#x798F;&#x888B;&#xFF0C;&#x6709;&#x597D;&#x51E0;&#x4EF6;&#x793C;&#x54C1;&#xFF0C;&#x9010;&#x4E2A;&#x9010;&#x4E2A;&#x9001;</li>
<li>&#x9001;&#x5230;&#x7B2C;3&#x4E2A;&#x53D1;&#x73B0;&#x6CA1;&#x8D27;</li>
<li>&#x56DE;&#x5230;&#x5907;&#x5FD8;&#x5F55;&#x8BB0;&#x4E0B;&#xFF0C;&#x8FD9;&#x5F20;&#x6263;&#x6B3E;&#x8BA2;&#x5355;&#x7B2C;3&#x4EF6;&#x6CA1;&#x53D1;&#x8D27;</li>
<li>job&#x662F;&#x8001;&#x677F;&#xFF0C;&#x4E13;&#x95E8;&#x76D1;&#x5DE5;</li>
<li>&#x4E00;&#x67E5;&#x5907;&#x5FD8;&#x5F55;&#x6709;&#x8BA2;&#x5355;&#x8FD8;&#x6CA1;&#x5B8C;&#xFF0C;&#x50AC;Consumer&#x518D;&#x6765;</li>
<li>&#x54EA;&#x91CC;&#x5931;&#x8D25;&#x54EA;&#x91CC;&#x91CD;&#x6765;</li>
<li>&#x5168;&#x90E8;&#x641E;&#x5B9A;</li>
<li>&#x62B9;&#x6389;&#x5907;&#x5FD8;&#x5F55;</li>
</ol>
<h1 id="&#x5E42;&#x7B49;&#x63A5;&#x53E3;&#x8BA2;&#x5355;&#x8BBE;&#x8BA1;">&#x5E42;&#x7B49;&#x63A5;&#x53E3;&#x8BA2;&#x5355;&#x8BBE;&#x8BA1;</h1>
<p>&#x65E0;&#x8BBA;&#x662F;&#x540C;&#x6B65;&#x63A5;&#x53E3;&#x6216;&#x662F;&#x5F02;&#x6B65;&#x63A5;&#x53E3;&#xFF0C;&#x63A5;&#x53E3;&#x7684;&#x5E42;&#x7B49;&#x8BBE;&#x8BA1;&#x90FD;&#x662F;&#x81F3;&#x5173;&#x91CD;&#x8981;&#x7684;</p>
<p>&#x5173;&#x4E8E;&#x5E42;&#x7B49;&#x63A5;&#x53E3;&#x53CA;&#x6570;&#x636E;&#x5E93;&#x8BBE;&#x8BA1;&#xFF0C;&#x53C2;&#x8003;<a href="../Mysql/&#x7ECF;&#x5178;&#x6570;&#x636E;&#x5E93;&#x8BBE;&#x8BA1;&#x6848;&#x4F8B;.html#&#x5E42;&#x7B49;&#x63A5;&#x53E3;&#x8BA2;&#x5355;&#x8BBE;&#x8BA1;">&#x5E42;&#x7B49;&#x63A5;&#x53E3;&#x8BA2;&#x5355;&#x8BBE;&#x8BA1;</a></p>
<h1 id="spring&#x4E8B;&#x52A1;">Spring&#x4E8B;&#x52A1;</h1>
<h2 id="&#x6CE8;&#x89E3;transactional&#x53C2;&#x6570;&#x8BF4;&#x660E;">&#x6CE8;&#x89E3;@Transactional&#x53C2;&#x6570;&#x8BF4;&#x660E;</h2>
<pre><code class="lang-java"><span class="hljs-comment">// readOnly=true&#x53EA;&#x8BFB;,&#x4E0D;&#x80FD;&#x66F4;&#x65B0;,&#x5220;&#x9664; </span>
<span class="hljs-meta">@Transactional</span> (propagation = Propagation.REQUIRED,readOnly=<span class="hljs-keyword">true</span>) 
<span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x8D85;&#x65F6;&#x65F6;&#x95F4;</span>
<span class="hljs-meta">@Transactional</span> (propagation = Propagation.REQUIRED,timeout=<span class="hljs-number">30</span>)
<span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x6570;&#x636E;&#x5E93;&#x9694;&#x79BB;&#x7EA7;&#x522B;</span>
<span class="hljs-meta">@Transactional</span> (propagation = Propagation.REQUIRED,isolation=Isolation.DEFAULT)
</code></pre>
<h2 id="&#x6CE8;&#x610F;&#x4E8B;&#x9879;">&#x6CE8;&#x610F;&#x4E8B;&#x9879;</h2>
<ol>
<li>&#x5728;&#x9700;&#x8981;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x7684;&#x5730;&#x65B9;&#x52A0;@Transactional &#x6CE8;&#x89E3;&#x3002;@Transactional &#x6CE8;&#x89E3;&#x53EF;&#x4EE5;&#x88AB;&#x5E94;&#x7528;&#x4E8E;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;&#x548C;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;&#x3001;&#x7C7B;&#x5B9A;&#x4E49;&#x548C;&#x7C7B;&#x7684; public &#x65B9;&#x6CD5;&#x4E0A;&#x3002;</li>
<li>@Transactional &#x6CE8;&#x89E3;&#x53EA;&#x80FD;&#x5E94;&#x7528;&#x5230; public &#x53EF;&#x89C1;&#x5EA6;&#x7684;&#x65B9;&#x6CD5;&#x4E0A;&#x3002; &#x5982;&#x679C;&#x4F60;&#x5728; protected&#x3001;private &#x6216;&#x8005; package-visible &#x7684;&#x65B9;&#x6CD5;&#x4E0A;&#x4F7F;&#x7528; @Transactional &#x6CE8;&#x89E3;&#xFF0C;&#x5B83;&#x4E5F;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x4F46;&#x662F;&#x8FD9;&#x4E2A;&#x88AB;&#x6CE8;&#x89E3;&#x7684;&#x65B9;&#x6CD5;&#x5C06;&#x4E0D;&#x4F1A;&#x5C55;&#x793A;&#x5DF2;&#x914D;&#x7F6E;&#x7684;&#x4E8B;&#x52A1;&#x8BBE;&#x7F6E;&#x3002;</li>
<li>&#x6CE8;&#x610F;&#x4EC5;&#x4EC5; @Transactional &#x6CE8;&#x89E3;&#x7684;&#x51FA;&#x73B0;&#x4E0D;&#x8DB3;&#x4E8E;&#x5F00;&#x542F;&#x4E8B;&#x52A1;&#x884C;&#x4E3A;&#xFF0C;&#x5B83;&#x4EC5;&#x4EC5; &#x662F;&#x4E00;&#x79CD;&#x5143;&#x6570;&#x636E;&#x3002;&#x5FC5;&#x987B;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;&#x914D;&#x7F6E;&#x5143;&#x7D20;&#xFF0C;&#x624D;&#x771F;&#x6B63;&#x5F00;&#x542F;&#x4E86;&#x4E8B;&#x52A1;&#x884C;&#x4E3A;&#x3002;</li>
<li>&#x901A;&#x8FC7; &#x5143;&#x7D20;&#x7684; &#x201C;proxy-target-class&#x201D; &#x5C5E;&#x6027;&#x503C;&#x6765;&#x63A7;&#x5236;&#x662F;&#x57FA;&#x4E8E;&#x63A5;&#x53E3;&#x7684;&#x8FD8;&#x662F;&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x4EE3;&#x7406;&#x88AB;&#x521B;&#x5EFA;&#x3002;&#x5982;&#x679C; &#x201C;proxy-target-class&#x201D; &#x5C5E;&#x503C;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A; &#x201C;true&#x201D;&#xFF0C;&#x90A3;&#x4E48;&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x4EE3;&#x7406;&#x5C06;&#x8D77;&#x4F5C;&#x7528;&#xFF08;&#x8FD9;&#x65F6;&#x9700;&#x8981;CGLIB&#x5E93;cglib.jar&#x5728;CLASSPATH&#x4E2D;&#xFF09;&#x3002;&#x5982;&#x679C; &#x201C;proxy-target-class&#x201D; &#x5C5E;&#x503C;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A; &#x201C;false&#x201D; &#x6216;&#x8005;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x88AB;&#x7701;&#x7565;&#xFF0C;&#x90A3;&#x4E48;&#x6807;&#x51C6;&#x7684;JDK&#x57FA;&#x4E8E;&#x63A5;&#x53E3;&#x7684;&#x4EE3;&#x7406;&#x5C06;&#x8D77;&#x4F5C;&#x7528;&#x3002;</li>
<li>Spring&#x56E2;&#x961F;&#x5EFA;&#x8BAE;&#x5728;&#x5177;&#x4F53;&#x7684;&#x7C7B;&#xFF08;&#x6216;&#x7C7B;&#x7684;&#x65B9;&#x6CD5;&#xFF09;&#x4E0A;&#x4F7F;&#x7528; @Transactional &#x6CE8;&#x89E3;&#xFF0C;&#x800C;&#x4E0D;&#x8981;&#x4F7F;&#x7528;&#x5728;&#x7C7B;&#x6240;&#x8981;&#x5B9E;&#x73B0;&#x7684;&#x4EFB;&#x4F55;&#x63A5;&#x53E3;&#x4E0A;&#x3002;&#x5728;&#x63A5;&#x53E3;&#x4E0A;&#x4F7F;&#x7528; @Transactional &#x6CE8;&#x89E3;&#xFF0C;&#x53EA;&#x80FD;&#x5F53;&#x4F60;&#x8BBE;&#x7F6E;&#x4E86;&#x57FA;&#x4E8E;&#x63A5;&#x53E3;&#x7684;&#x4EE3;&#x7406;&#x65F6;&#x5B83;&#x624D;&#x751F;&#x6548;&#x3002;&#x56E0;&#x4E3A;&#x6CE8;&#x89E3;&#x662F; &#x4E0D;&#x80FD;&#x7EE7;&#x627F; &#x7684;&#xFF0C;&#x8FD9;&#x5C31;&#x610F;&#x5473;&#x7740;&#x5982;&#x679C;&#x6B63;&#x5728;&#x4F7F;&#x7528;&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x4EE3;&#x7406;&#x65F6;&#xFF0C;&#x90A3;&#x4E48;&#x4E8B;&#x52A1;&#x7684;&#x8BBE;&#x7F6E;&#x5C06;&#x4E0D;&#x80FD;&#x88AB;&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x4EE3;&#x7406;&#x6240;&#x8BC6;&#x522B;&#xFF0C;&#x800C;&#x4E14;&#x5BF9;&#x8C61;&#x4E5F;&#x5C06;&#x4E0D;&#x4F1A;&#x88AB;&#x4E8B;&#x52A1;&#x4EE3;&#x7406;&#x6240;&#x5305;&#x88C5;&#x3002;</li>
<li>@Transactional &#x7684;&#x4E8B;&#x52A1;&#x5F00;&#x542F;&#xFF0C;&#x6216;&#x8005;&#x662F;&#x57FA;&#x4E8E;&#x63A5;&#x53E3;&#x7684; &#x6216;&#x8005;&#x662F;&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x4EE3;&#x7406;&#x88AB;&#x521B;&#x5EFA;&#x3002;&#x6240;&#x4EE5;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x7C7B;&#x4E2D;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x53E6;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x6709;&#x4E8B;&#x52A1;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x4E8B;&#x52A1;&#x662F;&#x4E0D;&#x4F1A;&#x8D77;&#x4F5C;&#x7528;&#x7684;&#x3002;</li>
</ol>
<h2 id="&#x56DE;&#x6EDA;">&#x56DE;&#x6EDA;</h2>
<p>&#x9ED8;&#x8BA4;&#x9047;&#x5230;throw new RuntimeException(&quot;...&quot;);&#x4F1A;&#x56DE;&#x6EDA;
&#x6355;&#x83B7;&#x7684;throw new Exception(&quot;...&quot;);&#x4E0D;&#x4F1A;&#x56DE;&#x6EDA;</p>
<p>&#x9700;&#x8981;&#x6355;&#x83B7;Exception&#x56DE;&#x6EDA;&#x65B9;&#x6CD5;&#xFF1A;<code>rollbackFor = Exception.class</code></p>
<p>&#x624B;&#x52A8;&#x56DE;&#x6EDA;&#x65B9;&#x6CD5;&#xFF1A;<code>TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();</code></p>
<pre><code class="lang-java"><span class="hljs-meta">@Transactional</span>(propagation = Propagation.REQUIRES_NEW,
            rollbackFor = Exception.class, isolation = Isolation.REPEATABLE_READ)
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">testInsert</span><span class="hljs-params">(<span class="hljs-keyword">int</span> index)</span> <span class="hljs-keyword">throws</span> Exception </span>{

        OrderDO orderDO = <span class="hljs-keyword">new</span> OrderDO();
        orderDO.setThirdOrderId(<span class="hljs-string">&quot;1000&quot;</span>);

        <span class="hljs-keyword">int</span> rowCount = <span class="hljs-keyword">this</span>.orderMapper.insertOrder(orderDO);
        <span class="hljs-keyword">if</span> (index == <span class="hljs-number">1</span>) {
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> RuntimeException(<span class="hljs-string">&quot;wrong&quot;</span>);
        }
        <span class="hljs-keyword">if</span> (index == <span class="hljs-number">2</span>) {
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Exception(<span class="hljs-string">&quot;wrong&quot;</span>);
        }
        <span class="hljs-keyword">if</span> (index == <span class="hljs-number">3</span>) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; tgor.top 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-04-23 15:32:53
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../Redis/Redis.html" class="navigation navigation-prev " aria-label="Previous page: 分布式缓存Redis">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="分布式事务.html#事务消息" class="navigation navigation-next " aria-label="Next page: 可靠事务消息">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"分布式事务","level":"1.2.10","depth":2,"next":{"title":"可靠事务消息","level":"1.2.11","depth":2,"anchor":"#事务消息","path":"Java-其他库/分布式事务.md","ref":"Java-其他库/分布式事务.md#事务消息","articles":[]},"previous":{"title":"分布式缓存Redis","level":"1.2.9","depth":2,"path":"Redis/Redis.md","ref":"Redis/Redis.md","articles":[]},"dir":"ltr"},"config":{"plugins":["chapter-fold","splitter","tbfed-pagefooter","page-toc-button","-search","search-pro","popup","back-to-top-button","code","copy-code-button"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy tgor.top 2019","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"fontsettings":{"theme":"sepia","family":"serif","size":1},"highlight":{},"page-toc-button":{"maxTocDepth":2,"minTocSize":2},"back-to-top-button":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"tgor","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"tgor note","gitbook":"*","description":"tgor生活工作记录"},"file":{"path":"Java-其他库/分布式事务.md","mtime":"2020-04-23T07:32:53.351Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-04-29T08:43:24.127Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-page-toc-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

